package org.fujay.langchain4jserver.domain.application.event;

import lombok.Getter;
import org.fujay.langchain4jserver.domain.application.vo.AppConfigSnapshot;
import org.fujay.langchain4jserver.domain.application.vo.AppId;
import org.fujay.langchain4jserver.domain.application.vo.Version;
import org.springframework.context.ApplicationEvent;

@Getter
public class AppConfigChangedEvent extends ApplicationEvent {

    // Getters
    private final AppId appId;
    private final Version newVersion;
    private final AppConfigSnapshot newConfigSnapshot;

    // Add old snapshot if needed

    /**
     * Create a new AppConfigChangedEvent.
     *
     * @param source            the component that published the event
     * @param appId             the ID of the application whose configuration changed
     * @param newVersion        the new configuration version
     * @param newConfigSnapshot the snapshot of the new configuration
     */
    public AppConfigChangedEvent(
            Object source, AppId appId, Version newVersion, AppConfigSnapshot newConfigSnapshot) {
        super(source);
        this.appId = appId;
        this.newVersion = newVersion;
        this.newConfigSnapshot = newConfigSnapshot;
    }
}
